﻿using CodeGenerator.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace CodeGenerator.BaseUI
{
    public partial class BaseFormEx : DockContent
    {
        public BaseFormEx()
        {
            InitializeComponent();
            this.TabPageContextMenuStrip = contextMenuStrip1;
        }

        /// <summary>
        /// 关闭所有文档
        /// </summary>
        private void CloseAllDocuments()
        {
            DockContentCollection contents = DockPanel.Contents;

            foreach(var content in contents)
            {
                if (content.DockHandler.DockState == DockState.Document)
                {
                    content.DockHandler.IsHidden=true;
                }
            }

          
        }

        /// <summary>
        /// 关闭其他窗体
        /// </summary>
        private void CloseOtherDocuments()
        {
            DockContentCollection contents = DockPanel.Contents;

            foreach (var content in contents)
            {
                if (content.DockHandler.DockState == DockState.Document && DockPanel.ActiveContent != content )
                {
                    content.DockHandler.Hide();
                }
            }
        }

        private void tsmi_closeAllDocument_Click(object sender, EventArgs e)
        {
            CloseAllDocuments();
        }

        private void tsmi_closeCurrentDocuemnt_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void tsmi_closeOtherDocument_Click(object sender, EventArgs e)
        {
            CloseOtherDocuments();
        }
    }
}
